package com.itfreer.form.dao.metadata;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Index;
import javax.persistence.Table;

import org.springframework.beans.BeanUtils;

import com.itfreer.form.api.JdbcBaseEntity;
import com.itfreer.form.entity.metadata.DictionaryEntity;

/**
 * 定义字典类
 */
@Entity(name = "form_dictionary")
@Table(indexes = { @Index(name = "f_d_dicname", columnList = "s_dicname") })
@IdClass(value = DictionaryPKID.class)
public class JdbcDictionaryEntity implements JdbcBaseEntity<DictionaryEntity>, Serializable {

	private static final long serialVersionUID = -8443497714033818376L;

	/**
	 * 外键，所属的字典
	 */
	@Id
	@Column(name = "s_dicname", nullable = true)
	private String dicName;

	/**
	 * id值，主键，唯一值 系统应用中必需关联此值
	 */
	@Id
	@Column(name = "id", length = 50, nullable = false)
	private String id;

	/**
	 * 代码值
	 */
	@Column(name = "s_code", nullable = true)
	private String code;

	/**
	 * 显示名称
	 */
	@Column(name = "s_display", nullable = true)
	private String display;

	/**
	 * 拼音简称
	 */
	@Column(name = "s_abbreviation", nullable = true)
	private String abbreviation;

	/**
	 * 单位
	 */
	@Column(name = "s_units", nullable = true)
	private String units;

	/**
	 * 排序值
	 */
	@Column(name = "i_order", nullable = true)
	private Integer order;

	/**
	 * 是否有效
	 */
	@Column(name = "b_valid", nullable = true)
	private Boolean valid = true;

	/**
	 * 备注
	 */
	@Column(name = "s_info", nullable = true)
	private String info;

	/**
	 * 上级ID值
	 */
	@Column(name = "s_pid", nullable = true)
	private String pid;

	/**
	 * 级别
	 */
	@Column(name = "i_level", nullable = true)
	private Integer level;

	/**
	 * 是否为最后级别
	 */
	@Column(name = "b_leaf", nullable = true)
	private Boolean leaf;

	/**
	 * id值，主键，唯一值 系统应用中必需关联此值
	 */
	public String getId() {
		return id;
	}

	/**
	 * id值，主键，唯一值 系统应用中必需关联此值
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * 代码值
	 */
	public String getCode() {
		return code;
	}

	/**
	 * 代码值
	 */
	public void setCode(String code) {
		this.code = code;
	}

	/**
	 * 显示名称
	 */
	public String getDisplay() {
		return display;
	}

	/**
	 * 显示名称
	 */
	public void setDisplay(String display) {
		this.display = display;
	}

	/**
	 * 拼音简称
	 */
	public String getAbbreviation() {
		return abbreviation;
	}

	/**
	 * 拼音简称
	 */
	public void setAbbreviation(String abbreviation) {
		this.abbreviation = abbreviation;
	}

	/**
	 * 排序值
	 */
	public Integer getOrder() {
		return order;
	}

	/**
	 * 排序值
	 */
	public void setOrder(Integer order) {
		this.order = order;
	}

	/**
	 * 是否有效
	 */
	public Boolean getValid() {
		return valid;
	}

	/**
	 * 是否有效
	 */
	public void setValid(Boolean isValid) {
		this.valid = isValid;
	}

	/**
	 * 备注
	 */
	public String getInfo() {
		return info;
	}

	/**
	 * 备注
	 */
	public void setInfo(String info) {
		this.info = info;
	}

	/**
	 * 上级ID值
	 */
	public String getPid() {
		return pid;
	}

	/**
	 * 上级ID值
	 */
	public void setPid(String pid) {
		this.pid = pid;
	}

	/**
	 * 级别
	 */
	public Integer getLevel() {
		return level;
	}

	/**
	 * 级别
	 */
	public void setLevel(Integer level) {
		this.level = level;
	}

	/**
	 * 是否为最后节点
	 * 
	 * @return
	 */
	public Boolean getLeaf() {
		return leaf;
	}

	/**
	 * 是否为最后节点
	 */
	public void setLeaf(Boolean leaf) {
		this.leaf = leaf;
	}

	public String getUnits() {
		return units;
	}

	public void setUnits(String units) {
		this.units = units;
	}

	public String getDicName() {
		return dicName;
	}

	public void setDicName(String dicName) {
		this.dicName = dicName;
	}

	@Override
	public DictionaryEntity toEntity() {
		DictionaryEntity toEntity = new DictionaryEntity();
		BeanUtils.copyProperties(this, toEntity);
		return toEntity;
	}

	@Override
	public void from(DictionaryEntity t) {
		BeanUtils.copyProperties(t, this);
	}
}
